import request from '@/config/axios'

// 文件上传记录 VO
export interface FileUploadVO {
  fileName: string // 原始文件名称
  filePath: string // 服务器存储路径
  fileSize: number // 文件大小（字节）
  fileType: string // 文件类型（扩展名）
  status: string // 状态（draft-草稿/completed-完成/failed-失败）
  resultJson: string // 识别结果（JSON格式）
  uploadUserId: number // 上传用户ID
  uploadIp: string // 上传IP地址
}

// 文件上传记录 API
export const FileUploadApi = {
  // 查询文件上传记录分页
  getFileUploadPage: async (params: any) => {
    return await request.get({ url: `/system/file-upload/page`, params })
  },

  // 查询文件上传记录详情
  getFileUpload: async (id: number) => {
    return await request.get({ url: `/system/file-upload/get?id=` + id })
  },

  // 新增文件上传记录
  createFileUpload: async (data: any) => {
    return await request.post({ url: `/system/file-upload/create`, data })
  },

  // 修改文件上传记录
  updateFileUpload: async (data: FileUploadVO) => {
    return await request.put({ url: `/system/file-upload/update`, data })
  },

  // 删除文件上传记录
  deleteFileUpload: async (id: number) => {
    return await request.delete({ url: `/system/file-upload/delete?id=` + id })
  },

  // 导出文件上传记录 Excel
  exportFileUpload: async (params) => {
    return await request.download({ url: `/system/file-upload/export-excel`, params })
  },
  // 上传文件
  aiFileUpload: async (data) => {
    const headers = {
      'Content-Type': 'multipart/form-data'
    }
    return await request.post({ url: `/strategy/upload`, data , headers})
  },
  // 执行数据分析
  aiAnalyze: async (params) => {
    return await request.get({ url: `/strategy/analyze`, params })
  },
  //分析图片
  aiAnalyzeWithPic: async (params) => {
    return await request.get({ url: `/strategy/analyzeWithPic`, params })
  },
  //图片识别
  aiAnalyzeWithOcr: async (params) => {
    return await request.get({ url: `/strategy/analyzeWithOcr`, params })
  },
  aiDownload: async (params) => {
    return await request.download({ url: `/strategy/download`, params })
  },
}